package com.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.common.result.Result;
import com.example.entity.vo.PurchaseOrder.PurchaseOrderTypeVo;
import com.example.entity.yifei.Cmsmq;
import com.example.service.CmsmqService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Api(tags = "采购单相关接口")
@RequestMapping("/api/purchaseOrder")
@RestController
public class PurchaseOrderController {

    @Autowired
    private CmsmqService cmsmqService;

    @ApiOperation("采购单单别")
    @PostMapping("purchaseOrderType")
    public Result<List<PurchaseOrderTypeVo>> purchaseOrderType() {

        LambdaQueryWrapper<Cmsmq> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Cmsmq::getMq003, "33");
        List<Cmsmq> list = cmsmqService.list(wrapper);
        List<PurchaseOrderTypeVo> res = new ArrayList<>();
        for(Cmsmq cmsmq : list) {
            PurchaseOrderTypeVo purchaseOrderTypeVo = new PurchaseOrderTypeVo();
            BeanUtils.copyProperties(cmsmq, purchaseOrderTypeVo);
            res.add(purchaseOrderTypeVo);
        }
        return Result.success(res);
    }




}
